#include "Math/Quaternion.h"
#include "Framework/Prerequisites.h"
#include "Math/Matrix3.h"

namespace tyro
{

	namespace Math
	{

		template < class T >
		const Quaternion<T> Quaternion<T>::ZERO(0,0,0,0);

		template < class T >
		const Quaternion<T> Quaternion<T>::IDENTITY(0,0,0,1);

		template < class T >
		void tyro::Math::Quaternion<T>::ToRotationMatix( Matrix3<T>& mat ) const
		{
			T xV  = x+x;
			T yV  = y+y;
			T zV  = z+z;
			T wxV = xV*w;
			T wyV = yV*w;
			T wzV = zV*w;
			T xxV = xV*x;
			T xyV = yV*x;
			T xzV = zV*x;
			T yyV = yV*y;
			T yzV = zV*y;
			T zzV = zV*z;

			mat.m00 = 1.0f-(yyV+zzV);
			mat.m01 = xyV-wzV;
			mat.m02 = xzV+wyV;
			mat.m10 = xyV+wzV;
			mat.m11 = 1.0f-(xxV+zzV);
			mat.m12 = yzV-wxV;
			mat.m20 = xzV-wyV;
			mat.m21 = yzV+wxV;
			mat.m22 = 1.0f-(xxV+yyV);
		}

		template class Quaternion< tyro::FLOAT_32 >; 
		template class Quaternion< tyro::FLOAT_64 >; 


	}

}